package arithmetic1.test1;

import java.util.Scanner;

public class J {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        String str1=scanner.nextLine();
        String str1s[]=str1.split("[ ]");
        int n=Integer.parseInt(str1s[0]);
        int m=Integer.parseInt(str1s[1]);
        int arr1[][]=new int[n][m];
        int arr2[][]=new int[m][n];
        for(int i=0;i<n;i++){
            String str=scanner.nextLine();
            String strs[]=str.split("[ ]");
            for(int j=0;j<strs.length;j++){
                arr1[i][j]=Integer.parseInt(strs[j]);
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                arr2[j][i]=arr1[i][j];
            }
        }
        for(int arr[]:arr2){
            for(int num:arr){
                System.out.print(num+" ");
            }
            System.out.println();
        }
    }
}
